<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<style>
    body {
        padding: 50px;
    }
    
    .mydiv {
        height: 300px;
        width: 300px;
        border: 1px solid #ccc;
        margin-bottom: 20px;
        display: inline-block;
    }
    
    .case1 {
        transform: skewX(-45deg);
    }
    /* 但是，这导致它的内容也发生了斜向变形，这很不好看，而且难读（参
见图3-14）。有没有办法只让容器的形状倾斜，而保持其内容不变呢？ */
    /* 嵌套元素方案 */
    
    .case2 {
        transform: skewX(-45deg);
    }
    
    .case2 div {
        transform: skewX(45deg);
    }
    /* 伪元素方案 */
    
    .case3 {
        position: relative;
        display: inline-block;
        padding: .5em 1em;
        border: 0;
        margin: .5em;
        background: transparent;
        color: white;
        text-transform: uppercase;
        text-decoration: none;
        font: bold 200%/1 sans-serif;
    }
    
    .case3::before {
        content: '';
        /* To generate the box */
        position: absolute;
        top: 0;
        right: 0;
        bottom: 0;
        left: 0;
        z-index: -1;
        background: #58a;
        transform: skew(45deg);
    }
</style>

<body>
    <div class="mydiv case1">ddddddddddddd</div>
    <div class="mydiv case2">
        <div>Click me</div>
    </div>
    <div class="mydiv case3">clickme </div>
</body>

</html>